package com.example.configdemo.controller;

import com.example.configdemo.model.Student;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class YmlController {
    @Value("${key}")
    private String key;

    @PostConstruct//初始化方法注解,表示那些方法要初始化
    public void readVal1(){
        System.out.println(key);
        System.out.println(serverPort);
    }

    @Value("${server.port}")//这俩拿值是一样的
    private Integer serverPort;

    @Autowired
    private Student student;

    @PostConstruct
    public void getResult(){
        System.out.println(student);
    }

}
